using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text;
using System.Data; 
using yq.IBase; 
using yq.Dictionary; 
using yq.Basis; 
using yq.Model.Logic;
using System.Collections; 
using Db; 
using System.Data.Common;

namespace yq.Model.Base 
{
    ///<summary>
    /// User_Account - 用户表 - 对象基础类
    /// </summary>
    ///<typeparam name="T"></typeparam>
    public abstract class IUserAccount<T> :ModelBase<UserAccount> where T : UserAccount, new()
    {
        /// <summary>
        /// 写入主键值
        /// </summary>
        /// <param name="Id">主键</param>
        protected internal override void SetKeyValue(dynamic Id)
        {
            this.UserId = Id;
        }

        /// <summary>
        /// 获取主键值
        /// </summary>
        /// <returns></returns>
        protected internal override dynamic GetKeyValue()
        {
            return UserId;
        }

        /// <summary>
        /// 为本对象赋值
        /// </summary>
        /// <param name="dy"></param>
        public override void SetValue(dynamic dy) 
        {
           this.UserId=dy.UserId;
           this.NickName=dy.NickName;
           this.State=dy.State;
           this.CreateTtime=dy.CreateTtime;
           this.TypeId=dy.TypeId;
           this.PurviewTeamID=dy.PurviewTeamID;
        } 

        #region 定义属性

     
         /// <summary>
        /// 用户ID
        /// </summary>
        private String _UserId = "";
      
        /// <summary>
        /// 用户ID
        /// </summary>
        public String UserId
        {
            get 
            {
              return   (this._UserId); 
            }

            set 
            {
                    _UserId= value;  
            }
        }
       
     
         /// <summary>
        /// 昵称
        /// </summary>
        private String _NickName = "";
      
        /// <summary>
        /// 昵称
        /// </summary>
        public String NickName
        {
            get 
            {
              return   (this._NickName); 
            }

            set 
            {
                    _NickName= value;  
            }
        }
       
     
         /// <summary>
        /// 状态
        /// </summary>
        private int _State =-1;
      
        /// <summary>
        /// 状态
        /// </summary>
        public yq.Enums.UserAccount.State State
        {
            get 
            {
              return   (yq.Enums.UserAccount.State)this._State;  
            }

            set 
            {
                    _State= value.GetHashCode(); 
            }
        }
       
     
         /// <summary>
        /// 注册时间
        /// </summary>
        private DateTime _CreateTtime =DateTime.MinValue;
      
        /// <summary>
        /// 注册时间
        /// </summary>
        public DateTime CreateTtime
        {
            get 
            {
              return   (this._CreateTtime); 
            }

            set 
            {
                    _CreateTtime= value;  
            }
        }
       
     
         /// <summary>
        /// 类型
        /// </summary>
        private int _TypeId =int.MinValue;
      
        /// <summary>
        /// 类型
        /// </summary>
        public int TypeId
        {
            get 
            {
              return   (this._TypeId); 
            }

            set 
            {
                    _TypeId= value;  
            }
        }
       
     
         /// <summary>
        /// 权限组ID
        /// </summary>
        private String _PurviewTeamID = "";
      
        /// <summary>
        /// 权限组ID
        /// </summary>
        public String PurviewTeamID
        {
            get 
            {
              return   (this._PurviewTeamID); 
            }

            set 
            {
                    _PurviewTeamID= value;  
            }
        }
       

      #endregion 定义属性 

          protected internal override void SetValue(UserAccount info, DataRow row) 
          { 
               if (row == null) 
               { 
                 info.IsLoad = false; 
               }
               else 
               { 
                  info.IsLoad = true; 
                  
                  if(row["UserId"]!= DBNull.Value)
                  {
                  info.UserId=row["UserId"].ToString();
                 }
                 
                  
                  if(row["NickName"]!= DBNull.Value)
                  {
                  info.NickName=row["NickName"].ToString();
                 }
                 
                  
                  if(row["State"]!= DBNull.Value)
                  {
                  info.State=  (yq.Enums.UserAccount.State)(row["State"]) ;
                 }
                 
                  
                  if(row["CreateTtime"]!= DBNull.Value)
                  {
                  info.CreateTtime=Convert.ToDateTime(row["CreateTtime"]);
                 }
                 
                  
                  if(row["TypeId"]!= DBNull.Value)
                  {
                  info.TypeId=Convert.ToInt32(row["TypeId"]);
                 }
                 
                  
                  if(row["PurviewTeamID"]!= DBNull.Value)
                  {
                  info.PurviewTeamID=row["PurviewTeamID"].ToString();
                 }
                 
               } 

          } 

        protected internal override void GetDbParameters(DbCommand comm, UserAccount info, DbHelper cn) 
        { 
             
                cn.AddInParameter(comm, "@UserId", DbType.String,ParameterTool.GetObj( info._UserId )); 
            
             
                cn.AddInParameter(comm, "@NickName", DbType.String,ParameterTool.GetObj( info._NickName )); 
            
             
                cn.AddInParameter(comm, "@State", DbType.Int32,ParameterTool.GetObj( info._State )); 
            
             
                cn.AddInParameter(comm, "@CreateTtime", DbType.DateTime,ParameterTool.GetObj( info._CreateTtime )); 
            
             
                cn.AddInParameter(comm, "@TypeId", DbType.Int32,ParameterTool.GetObj( info._TypeId )); 
            
             
                cn.AddInParameter(comm, "@PurviewTeamID", DbType.String,ParameterTool.GetObj( info._PurviewTeamID )); 
            
        } 

    } 
} 